package net.towee.client.com.app.presenter;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.inject.Inject;

import net.towee.client.com.app.RememberForm;
import net.towee.client.com.app.presenter.RememberFormPresenter.Display;
import net.towee.client.managers.AccountHelper;

public class RememberFormPresenter implements RememberForm, ClickHandler {

	public interface Display extends IsWidget {
		HasClickHandlers getRememberButton();

		void showForm();
	}

	private final Display display;
	private final AccountHelper account;
	
	@Inject
	public RememberFormPresenter(Display display, AccountHelper account) {
		this.display = display;
		this.account = account;
		
		display.getRememberButton().addClickHandler(this);
	}
	
	@Override
	public void go(HasWidgets container) {
		display.showForm();
	}

	@Override
	public void onClick(ClickEvent event) {
		account.rememberMe();
	}

}
